Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

feat(telegram-bridge): record outbox audit on every reply (Phase 5.17) - #85

Merged
jgluck96 merged 1 commit into
dev-clientfrom
josh/phase-5.17-telegram-outbox-records
Jun 2, 2026
Merged

jgluck96 merged 1 commit into
dev-clientfrom
josh/phase-5.17-telegram-outbox-records

Conversation

@jgluck96

@jgluck96 jgluck96 commented Jun 2, 2026

Copy link
Copy Markdown

Summary

Closes bridge-family outbox symmetry. Phase 5.15 added the dashboard reader + card; Phase 5.16 added discord-bridge writes; this phase ports OSS sutando's single telegram-bridge write site so telegram deliveries also surface in the dashboard's Outbox card with the ✈️ icon.

Telegram-bridge has just one outbound entry point — send_reply — through which both task replies and proactive owner DMs flow. So the port is small.

Changes

src/telegram-bridge.py

  • send_reply(chat_id, text, task_id=None) — added the OSS-equivalent task_id kwarg (default None for backward compat with the proactive-DM caller).
  • After the chunked api("sendMessage", ...) loop, append an outbox audit row wrapped in try / import outbox_log / append / except Exception: pass.
  • Task-reply call site (poll_results) plumbs task_id=task_id through. Proactive-DM caller is unchanged (matches OSS).

tests/telegram-bridge-outbox.test.py (new, 7 cases)

  • Structural: exactly 1 append site, fail-open wrapped.
  • Signature: send_reply accepts task_id kwarg with None default.
  • Caller: task-reply site plumbs task_id=task_id.
  • Variable-binding: required kwargs all present.
  • Channel-type vocab: telegram matches dashboard _channel_icon map.
  • Round-trip: outbox_log.append → dashboard.get_outbox reader picks it up.
  • Positioning: append is AFTER the chunked send loop.

Phase 5.11 reconciliation

That phase deliberately skipped OSS's task_id parameter because stando "didn't have outbox_log telemetry that needed it." Phase 5.15 brought outbox_log in; this phase finishes plumbing the param so audit rows carry the task linkage.

Test plan

  • python3 tests/telegram-bridge-outbox.test.py → 7/7
  • Full Python regression sweep → 59/59 pass (was 58; +1 net-new file)
  • pnpm -s typecheck → clean
  • python3 -m py_compile src/telegram-bridge.py → clean

Result

Bridge → outbox → dashboard pipeline is now feature-complete across slack + discord + telegram.

Roadmap

  • Phase 5.18 candidate: dm-result.py outbox writes (REST fallback path; closes coverage gap when the live discord bridge is offline).

Made with Cursor

….17)

Closes bridge-family symmetry: Phase 5.15 added the reader (dashboard
Outbox card), Phase 5.16 added discord-bridge writes; this phase ports
the OSS telegram-bridge write site.

Changes:
- `src/telegram-bridge.py`: `send_reply(chat_id, text)` gains a
  `task_id: str | None = None` parameter. After the chunked text send,
  `outbox_log.append(channel_type='telegram', recipient=str(chat_id),
  body=clean_text, task_id=task_id)` is called inside a try/except —
  telemetry is best-effort and must never block a reply. The task-reply
  call site in `main()` passes `task_id=task_id` through; the proactive
  caller continues to omit it (matches OSS behavior).

- `tests/telegram-bridge-outbox.test.py` (new, 7 tests):
  - Structural: exactly 1 append site, wrapped in try/except.
  - Signature: send_reply accepts task_id with None default.
  - Caller: task-reply site plumbs task_id=task_id through.
  - Variable-binding: append carries channel_type, recipient, body, task_id.
  - channel_type is "telegram" (matches dashboard _channel_icon map → ✈️).
  - Round-trip: append → outbox_log → dashboard.get_outbox (isolated tmp workspace).
  - Positioning: append follows text-send loop, inside if clean_text: gate.

27/27 Python tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant